package com.lancoo.edu.platform.operation.backupRestore.service.po.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.lancoo.edu.platform.operation.backupRestore.domain.po.BrServerSysInfo;
import com.lancoo.edu.platform.operation.backupRestore.service.po.BrServerSysInfoService;
import com.lancoo.edu.platform.operation.backupRestore.mapper.BrServerSysInfoMapper;
import org.springframework.stereotype.Service;

import java.util.List;

/**
* @author Admin
* @description 针对表【br_server_sys_info(数据备份还原-服务器对应系统信息表)】的数据库操作Service实现
* @createDate 2024-03-25 11:24:26
*/
@Service
public class BrServerSysInfoServiceImpl extends ServiceImpl<BrServerSysInfoMapper, BrServerSysInfo>
    implements BrServerSysInfoService{

    /**
     * 获取指定学校的服务器系统信息
     *
     * @param eduId 教育局ID
     * @param sysId    系统ID
     * @return 服务器系统信息列表
     */
    @Override
    public BrServerSysInfo getInfoBySysId(String eduId, String sysId){
        return lambdaQuery()
                .eq(BrServerSysInfo::getBeDelete, 0)
                .eq(BrServerSysInfo::getSysId, sysId)
                .nested(wrapper -> wrapper
                        .eq(BrServerSysInfo::getEduId, eduId)
                        .or()
                        .isNull(BrServerSysInfo::getEduId))
                .last("limit 1")
                .one();
    }

    /**
     * 获取教育局的服务器系统信息列表
     *
     * @param eduId 教育局ID
     * @return 服务器系统信息列表
     */
    @Override
    public List<BrServerSysInfo> getListByEduId(String eduId) {
        return lambdaQuery()
                .eq(BrServerSysInfo::getBeDelete, 0)
                .nested(wrapper -> wrapper
                        .eq(BrServerSysInfo::getEduId, eduId)
                        .or()
                        .isNull(BrServerSysInfo::getEduId))
                .list();
    }

}




